<extend name="Layout:ly1"/>

<block name="head">
    <script>
        $(document).ready(function () {
          

            //添加
            $('#add').click(function(){
                layer.open({
                    type: 2,
                    title: '添加用户',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['50%', '580px'],
                    content: '{:U("Admin/Member/member_add")}'
                });
            })

            //查看信息
             $('body').delegate('table tr td .view','click',function(){
                var url = $(this).parents('tr').data('view');
                layer.open({
                    type: 2,
                    title: '查看详情',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['50%', '80%'],
                    content: url
                });
            })

            //编辑信息
            $('body').delegate('table tr td .update','click',function(){
                var url = $(this).parents('tr').data('edit');
                layer.open({
                    type: 2,
                    title: '编辑用户',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['50%', '540px'],
                    content: url
                });
            })

            //修改密码
            $('body').delegate('table tr td.acount','click',function(){
                var url = $(this).parents('tr').data('edit_pwd');
                layer.open({
                    type: 2,
                    title: '编辑用户',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['450px', '420px'],
                    content: url
                });
            })

            //修改头像
            $('body').delegate('table tr td.avatar','click',function(){
                var url = $(this).parents('tr').data('avatar');
                layer.open({
                    type: 2,
                    title: '修改头像',
                    shadeClose: true,
                    shade: 0.8,
                    area: ['450px', '330px'],
                    content: url
                });
            })

            //删除信息
            $('body').delegate('table tr td .delete','click',function(){
                var id = $(this).parents('tr').data('id');
                layer.confirm('你确定要删除吗？', {
                    btn: ['确定','取消'], //按钮
                    shade: [0.4, '#393D49'] //显示遮罩
                }, function(){
                    $.get("{:U('Admin/Member/member_delete')}",{"userid": id},function(msg){
                        if(msg == 1){
                            layer.msg("删除成功，1秒后自动关闭~~",{ico:1,time:1000},function(){
                                $('table tr#id_'+id).remove();
                            })
                        }else if(msg == 2){
                            layer.msg("参数异常，1秒后自动关闭~~",{ico:1,time:1000});
                        }else{
                            layer.msg("删除失败，1秒后自动关闭~~",{ico:1,time:1000});
                        }
                    })
                }, function(){

                });
            })
        });
    </script>
</block>

<block name="body">
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">会员列表</h1>
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        会员列表
                        <a id="add" class="pull-right">用户添加</a>
						
						
						
                    </div>
                    <!-- /.panel-heading -->
                    <div class="panel-body">
					
					<div class="row">
					    <form   action="__URL__/member_list"  method="post">
						<div class="col-sm-6">
						<div class="dataTables_filter" >
						<label>搜索:<input  class="form-control input-sm"     type="text" name="mobile"  value="{$mobile|default=''}"   placeholder="请输入手机号" ></label>
						  <input  type="submit" name="submit" style="margin-left:50px;" value="提交" />	
						</div>
						</div>
						</form>
						</div>
						
                        <div class="dataTable_wrapper">
						
						
						
						
                            <table class="table table-bordered table-hover">
                                <thead>
                                    <tr>
                                        <th align="center">ID</th>
                                        <th>帐号</th>
                                        <th>会员头像</th>
                                        <th>昵称</th>
                                        <th>用户姓名</th>
                                        <th>会员积分</th>
                                        <th>所在地区</th>
                                        <th>最后登录时间</th>
                                        <th>注册时间</th>
                                        <th>状态</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <foreach name="data" item="v" key="k" >
                                        <tr id="id_{$v.userid}" data-id="{$v.userid}" data-edit="{:U('Admin/Member/member_edit',['userid'=>$v['userid']])}" data-view="{:U('Admin/Member/member_profile',['userid'=>$v['userid']])}" data-edit_pwd="{:U('Admin/Member/member_edit_pwd',['userid'=>$v['userid']])}" data-avatar="{:U('Admin/Member/member_avatar',['userid'=>$v['userid']])}">
                                            <td align="center">{$v.userid}</td>
                                            <td id="acount" class="acount"><span title="点击修改密码">{$v.mobile}</span></td>
                                            <td id="avatar" class="avatar" align="center">
                                                <img src="<?php
												
												
												if($member_profile[$v['userid']]['avatar']){
												echo $constantconfig[0].substr($member_profile[$v['userid']]['avatar'],2,100);}else{
												echo $constantconfig[1].'images/thumb.jpg';};?>"
												width="36" height="36" style="border:1px solid #dbdbdb;padding: 2px;" title="点击修改头像" />
                                            </td>
											
                                            <td><?php  echo $member_profile[$v['userid']]['nickname'];?></td>
                                            <td><?php  echo $member_profile[$v['userid']]['truename'];?></td>
                                            <td><?php  echo $member_profile[$v['userid']]['score'];?></td>
											<td ><?php  echo $member_profile[$v['userid']]['address'];?></td>
                                         
                                            <td>{$v.last_login_time}</td>
                                            <td>{$v.addtime}</td>
                                            <td align="center">
                                                <if condition="$v.status eq 1">
                                                    <font color="green">正常</font>
                                                    <else />
                                                    <font color="red">禁用</font>
                                                </if>
                                            </td>
                                            <td align="center">
                                                <button class="btn btn-primary view">查看</button>
                                                <button class="btn btn-warning update">修改</button>
                                                <button class="btn btn-danger delete">删除</button>
                                            </td>
                                        </tr>
                                    </foreach>
									<tr>   <td  colspan="10"> {$page} </td> </tr>
                                </tbody>
                            </table>
							
							
							
                        </div>
                        <!-- /.table-responsive -->
                    </div>
                    <!-- /.panel-body -->
                </div>
                <!-- /.panel -->
            </div>
            <!-- /.col-lg-12 -->
        </div>
    </div>
    <!-- /#page-wrapper -->
</block>